﻿using System;
using System.Collections.Generic;
using System.Data;
using nkstdgia.common.ThamDinhGia.BusinessObjects;

namespace nkstdgia.common.ThamDinhGia.DataAccess
{
    public class CO_SO_HA_TANGDA
    {
        #region ***** Init Methods *****

        public CO_SO_HA_TANGDA()
        {
        }

        #endregion ***** Init Methods *****

        #region ***** Get Methods *****

        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public CO_SO_HA_TANG Populate(IDataReader myReader)
        {
            CO_SO_HA_TANG obj = new CO_SO_HA_TANG();
            obj.MA_HO_SO = (Int64)myReader["MA_HO_SO"];
            obj.DONG_HO_DIEN = (int)myReader["DONG_HO_DIEN"];
            obj.CAP_TREO = (int)myReader["CAP_TREO"];
            obj.CAP_NGAM = (int)myReader["CAP_NGAM"];
            obj.DONG_HO_NUOC = (int)myReader["DONG_HO_NUOC"];
            obj.AP_LUC_NUOC = (int)myReader["AP_LUC_NUOC"];
            obj.CHAT_LUONG_NUOC = (int)myReader["CHAT_LUONG_NUOC"];
            obj.TIENG_ON = (int)myReader["TIENG_ON"];
            obj.KHOI_BUI = (int)myReader["KHOI_BUI"];
            obj.TINH_TRANG_NGAP = (int)myReader["TINH_TRANG_NGAP"];
            obj.HE_THONG_CHIEU_SANG = (int)myReader["HE_THONG_CHIEU_SANG"];
            obj.CHOT_BAO_VE = (int)myReader["CHOT_BAO_VE"];
            obj.AN_NINH = (int)myReader["AN_NINH"];
            obj.GAN_CO_SO_GIAO_DUC = (int)myReader["GAN_CO_SO_GIAO_DUC"];
            obj.GAN_CO_SO_Y_TE = (int)myReader["GAN_CO_SO_Y_TE"];
            obj.GAN_CHO_TRUNG_TAM = (int)myReader["GAN_CHO_TRUNG_TAM"];
            obj.GAN_CO_SO_GIAI_TRI = (int)myReader["GAN_CO_SO_GIAI_TRI"];
            obj.GAN_DICH_VU_CONG_CONG = (int)myReader["GAN_DICH_VU_CONG_CONG"];
            obj.GAN_THONG_TIN_LIEN_LAC = (int)myReader["GAN_THONG_TIN_LIEN_LAC"];
            return obj;
        }

        /// <summary>
        /// Get CO_SO_HA_TANG by ma_ho_so
        /// </summary>
        /// <param name="ma_ho_so">MA_HO_SO</param>
        /// <returns>CO_SO_HA_TANG</returns>
        public CO_SO_HA_TANG GetByMA_HO_SO(Int64 ma_ho_so)
        {
            using (IDataReader reader = SqlHelper.ExecuteReader(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_GetByMA_HO_SO", Data.CreateParameter("MA_HO_SO", ma_ho_so)))
            {
                if (reader.Read())
                {
                    return Populate(reader);
                }
                return null;
            }
        }

        /// <summary>
        /// Get all of CO_SO_HA_TANG
        /// </summary>
        /// <returns>List<<CO_SO_HA_TANG>></returns>
        public List<CO_SO_HA_TANG> GetList()
        {
            using (IDataReader reader = SqlHelper.ExecuteReader(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_Get"))
            {
                List<CO_SO_HA_TANG> list = new List<CO_SO_HA_TANG>();
                while (reader.Read())
                {
                    list.Add(Populate(reader));
                }
                return list;
            }
        }

        /// <summary>
        /// Get DataSet of CO_SO_HA_TANG
        /// </summary>
        /// <returns>DataSet</returns>
        public DataSet GetDataSet()
        {
            return SqlHelper.ExecuteDataSet(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_Get");
        }

        /// <summary>
        /// Get all of CO_SO_HA_TANG paged
        /// </summary>
        /// <param name="recperpage">record per page</param>
        /// <param name="pageindex">page index</param>
        /// <returns>List<<CO_SO_HA_TANG>></returns>
        public List<CO_SO_HA_TANG> GetListPaged(int recperpage, int pageindex)
        {
            using (IDataReader reader = SqlHelper.ExecuteReader(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_GetPaged"
                            , Data.CreateParameter("recperpage", recperpage)
                            , Data.CreateParameter("pageindex", pageindex)))
            {
                List<CO_SO_HA_TANG> list = new List<CO_SO_HA_TANG>();
                while (reader.Read())
                {
                    list.Add(Populate(reader));
                }
                return list;
            }
        }

        /// <summary>
        /// Get DataSet of CO_SO_HA_TANG paged
        /// </summary>
        /// <param name="recperpage">record per page</param>
        /// <param name="pageindex">page index</param>
        /// <returns>DataSet</returns>
        public DataSet GetDataSetPaged(int recperpage, int pageindex)
        {
            return SqlHelper.ExecuteDataSet(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_GetPaged"
                            , Data.CreateParameter("recperpage", recperpage)
                            , Data.CreateParameter("pageindex", pageindex));
        }

        #endregion ***** Get Methods *****

        #region ***** Add Update Delete Methods *****

        /// <summary>
        /// Add a new CO_SO_HA_TANG within CO_SO_HA_TANG database table
        /// </summary>
        /// <param name="obj">CO_SO_HA_TANG</param>
        /// <returns>key of table</returns>
        public long Add(CO_SO_HA_TANG obj)
        {
            SqlHelper.ExecuteNonQuery(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_Add"
                            , Data.CreateParameter("MA_HO_SO", obj.MA_HO_SO)
                            , Data.CreateParameter("DONG_HO_DIEN", obj.DONG_HO_DIEN)
                            , Data.CreateParameter("CAP_TREO", obj.CAP_TREO)
                            , Data.CreateParameter("CAP_NGAM", obj.CAP_NGAM)
                            , Data.CreateParameter("DONG_HO_NUOC", obj.DONG_HO_NUOC)
                            , Data.CreateParameter("AP_LUC_NUOC", obj.AP_LUC_NUOC)
                            , Data.CreateParameter("CHAT_LUONG_NUOC", obj.CHAT_LUONG_NUOC)
                            , Data.CreateParameter("TIENG_ON", obj.TIENG_ON)
                            , Data.CreateParameter("KHOI_BUI", obj.KHOI_BUI)
                            , Data.CreateParameter("TINH_TRANG_NGAP", obj.TINH_TRANG_NGAP)
                            , Data.CreateParameter("HE_THONG_CHIEU_SANG", obj.HE_THONG_CHIEU_SANG)
                            , Data.CreateParameter("CHOT_BAO_VE", obj.CHOT_BAO_VE)
                            , Data.CreateParameter("AN_NINH", obj.AN_NINH)
                            , Data.CreateParameter("GAN_CO_SO_GIAO_DUC", obj.GAN_CO_SO_GIAO_DUC)
                            , Data.CreateParameter("GAN_CO_SO_Y_TE", obj.GAN_CO_SO_Y_TE)
                            , Data.CreateParameter("GAN_CHO_TRUNG_TAM", obj.GAN_CHO_TRUNG_TAM)
                            , Data.CreateParameter("GAN_CO_SO_GIAI_TRI", obj.GAN_CO_SO_GIAI_TRI)
                            , Data.CreateParameter("GAN_DICH_VU_CONG_CONG", obj.GAN_DICH_VU_CONG_CONG)
                            , Data.CreateParameter("GAN_THONG_TIN_LIEN_LAC", obj.GAN_THONG_TIN_LIEN_LAC)
            );
            return obj.MA_HO_SO;
        }

        /// <summary>
        /// updates the specified CO_SO_HA_TANG
        /// </summary>
        /// <param name="obj">CO_SO_HA_TANG</param>
        /// <returns></returns>
        public void Update(CO_SO_HA_TANG obj)
        {
            SqlHelper.ExecuteNonQuery(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_Update"
                            , Data.CreateParameter("MA_HO_SO", obj.MA_HO_SO)
                            , Data.CreateParameter("DONG_HO_DIEN", obj.DONG_HO_DIEN)
                            , Data.CreateParameter("CAP_TREO", obj.CAP_TREO)
                            , Data.CreateParameter("CAP_NGAM", obj.CAP_NGAM)
                            , Data.CreateParameter("DONG_HO_NUOC", obj.DONG_HO_NUOC)
                            , Data.CreateParameter("AP_LUC_NUOC", obj.AP_LUC_NUOC)
                            , Data.CreateParameter("CHAT_LUONG_NUOC", obj.CHAT_LUONG_NUOC)
                            , Data.CreateParameter("TIENG_ON", obj.TIENG_ON)
                            , Data.CreateParameter("KHOI_BUI", obj.KHOI_BUI)
                            , Data.CreateParameter("TINH_TRANG_NGAP", obj.TINH_TRANG_NGAP)
                            , Data.CreateParameter("HE_THONG_CHIEU_SANG", obj.HE_THONG_CHIEU_SANG)
                            , Data.CreateParameter("CHOT_BAO_VE", obj.CHOT_BAO_VE)
                            , Data.CreateParameter("AN_NINH", obj.AN_NINH)
                            , Data.CreateParameter("GAN_CO_SO_GIAO_DUC", obj.GAN_CO_SO_GIAO_DUC)
                            , Data.CreateParameter("GAN_CO_SO_Y_TE", obj.GAN_CO_SO_Y_TE)
                            , Data.CreateParameter("GAN_CHO_TRUNG_TAM", obj.GAN_CHO_TRUNG_TAM)
                            , Data.CreateParameter("GAN_CO_SO_GIAI_TRI", obj.GAN_CO_SO_GIAI_TRI)
                            , Data.CreateParameter("GAN_DICH_VU_CONG_CONG", obj.GAN_DICH_VU_CONG_CONG)
                            , Data.CreateParameter("GAN_THONG_TIN_LIEN_LAC", obj.GAN_THONG_TIN_LIEN_LAC)
            );
        }

        /// <summary>
        /// Delete the specified CO_SO_HA_TANG
        /// </summary>
        /// <param name="ma_ho_so">MA_HO_SO</param>
        /// <returns></returns>
        public void Delete(Int64 ma_ho_so)
        {
            SqlHelper.ExecuteNonQuery(Data.ConnectionString, CommandType.StoredProcedure, "sproc_CO_SO_HA_TANG_Delete", Data.CreateParameter("MA_HO_SO", ma_ho_so));
        }

        #endregion ***** Add Update Delete Methods *****
    }
}